﻿
namespace MefContrib.Models.Provider
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.Composition.Hosting;
    using System.ComponentModel.Composition.Primitives;
    using System.Linq;
    using System.Text;
    using MefContrib.Models.Provider.Validation;
    
    /// <summary>
    /// 
    /// </summary>
    public static class CompositionBatchExtensions
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static ComposablePart AddProviderPart(this CompositionBatch batch, object instance)
        {
            instance
                .Require("instance")
                .NotNull();

            ProviderComposablePart part =
                new ProviderComposablePart(instance);

            batch.AddPart(part);

            return part;
        }
    }
}